package StudyCode.summary.textfile;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFileAttributes;
import java.nio.file.attribute.PosixFilePermission;
import java.util.Set;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class MaintainingPOSIXFileAttributesUsingPosixFileAttributeView {
	public static void main(String[] args) throws Exception {
		Path path = Paths.get("home/docs/test.txt");
		PosixFileAttributeView view = Files.getFileAttributeView(path,
				PosixFileAttributeView.class);

		PosixFileAttributes attributes = view.readAttributes();
		System.out.println("分组: " + attributes.group());
		System.out.println("所有者: " + attributes.owner().getName());

		Set<PosixFilePermission> permissions = attributes.permissions();
		for (PosixFilePermission permission : permissions) {
			System.out.print(permission.name() + " ");
		}
	}
}
